package com.ruoyi.web.controller.solidProdution;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.solidProdution.domain.CftzInfo;
import com.ruoyi.solidProdution.service.ICftzInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产废台账Controller
 * 
 * @author ruoyi
 * @date 2021-09-02
 */
@RestController
@RequestMapping("/solidProdution/cftzInfo")
public class CftzInfoController extends BaseController
{
    @Autowired
    private ICftzInfoService cftzInfoService;

    /**
     * 查询产废台账列表
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cftzInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CftzInfo cftzInfo)
    {
        startPage();
        List<CftzInfo> list = cftzInfoService.selectCftzInfoList(cftzInfo);
        return getDataTable(list);
    }

    /**
     * 导出产废台账列表
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cftzInfo:export')")
    @Log(title = "产废台账", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CftzInfo cftzInfo)
    {
        List<CftzInfo> list = cftzInfoService.selectCftzInfoList(cftzInfo);
        ExcelUtil<CftzInfo> util = new ExcelUtil<CftzInfo>(CftzInfo.class);
        return util.exportExcel(list, "产废台账数据");
    }

    /**
     * 获取产废台账详细信息
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cftzInfo:query')")
    @GetMapping(value = "/{cftzId}")
    public AjaxResult getInfo(@PathVariable("cftzId") Long cftzId)
    {
        return AjaxResult.success(cftzInfoService.selectCftzInfoById(cftzId));
    }

    /**
     * 新增产废台账
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cftzInfo:add')")
    @Log(title = "产废台账", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CftzInfo cftzInfo)
    {
        return toAjax(cftzInfoService.insertCftzInfo(cftzInfo));
    }

    /**
     * 修改产废台账
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cftzInfo:edit')")
    @Log(title = "产废台账", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CftzInfo cftzInfo)
    {
        return toAjax(cftzInfoService.updateCftzInfo(cftzInfo));
    }

    /**
     * 删除产废台账
     */
    @PreAuthorize("@ss.hasPermi('solidProdution:cftzInfo:remove')")
    @Log(title = "产废台账", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cftzIds}")
    public AjaxResult remove(@PathVariable Long[] cftzIds)
    {
        return toAjax(cftzInfoService.deleteCftzInfoByIds(cftzIds));
    }
}
